import {
  FileIconAepIcon,
  FileIconAiIcon,
  FileIconAviIcon,
  FileIconCssIcon,
  FileIconCsvIcon,
  FileIconDmgIcon,
  FileIconDocIcon,
  FileIconDocxIcon,
  FileIconEpsIcon,
  FileIconExeIcon,
  FileIconFigIcon,
  FileIconGifIcon,
  FileIconHtmlIcon,
  FileIconImgIcon,
  FileIconInddIcon,
  FileIconJavaIcon,
  FileIconJpegIcon,
  FileIconJpgIcon,
  FileIconJsIcon,
  FileIconJsonIcon,
  FileIconMdIcon,
  FileIconMkvIcon,
  FileIconMp3Icon,
  FileIconMp4Icon,
  FileIconMpegIcon,
  FileIconNoneIcon,
  FileIconPdfIcon,
  FileIconPngIcon,
  FileIconPptIcon,
  FileIconPptxIcon,
  FileIconPsdIcon,
  FileIconRarIcon,
  FileIconRssIcon,
  FileIconSqlIcon,
  FileIconSvgIcon,
  FileIconTiffIcon,
  FileIconTxtIcon,
  FileIconWavIcon,
  FileIconWebpIcon,
  FileIconXlsIcon,
  FileIconXlsxIcon,
  FileIconXmlIcon,
  FileIconZipIcon,
} from '@blocksuite/icons/lit';

// TODO(@fundon): should be an extension, users can customize.
const iconMap = new Map([
  ['img', FileIconImgIcon],
  ['jpg', FileIconJpgIcon],
  ['jpeg', FileIconJpegIcon],
  ['png', FileIconPngIcon],
  ['webp', FileIconWebpIcon],
  ['tiff', FileIconTiffIcon],
  ['gif', FileIconGifIcon],
  ['svg', FileIconSvgIcon],
  ['eps', FileIconEpsIcon],
  ['pdf', FileIconPdfIcon],
  ['doc', FileIconDocIcon],
  ['docx', FileIconDocxIcon],
  ['txt', FileIconTxtIcon],
  ['csv', FileIconCsvIcon],
  ['xls', FileIconXlsIcon],
  ['xlsx', FileIconXlsxIcon],
  ['ppt', FileIconPptIcon],
  ['pptx', FileIconPptxIcon],
  ['fig', FileIconFigIcon],
  ['ai', FileIconAiIcon],
  ['psd', FileIconPsdIcon],
  ['indd', FileIconInddIcon],
  ['aep', FileIconAepIcon],
  ['mp3', FileIconMp3Icon],
  ['wav', FileIconWavIcon],
  ['mp4', FileIconMp4Icon],
  ['mpeg', FileIconMpegIcon],
  ['avi', FileIconAviIcon],
  ['mkv', FileIconMkvIcon],
  ['html', FileIconHtmlIcon],
  ['css', FileIconCssIcon],
  ['rss', FileIconRssIcon],
  ['md', FileIconMdIcon],
  ['sql', FileIconSqlIcon],
  ['js', FileIconJsIcon],
  ['json', FileIconJsonIcon],
  ['java', FileIconJavaIcon],
  ['xml', FileIconXmlIcon],
  ['exe', FileIconExeIcon],
  ['dmg', FileIconDmgIcon],
  ['zip', FileIconZipIcon],
  ['rar', FileIconRarIcon],
  ['none', FileIconNoneIcon],
]);

// It's `40 x 40` by default.
export function getAttachmentFileIcon(
  filetype: string,
  options: Parameters<typeof FileIconNoneIcon>[0] = {
    width: '2.5em',
    height: '2.5em',
    style: 'font-size: 16px',
  }
) {
  const Icon = iconMap.get(filetype) ?? FileIconNoneIcon;
  return Icon(options);
}
